{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5622d657-56d3-4eb8-9db2-29114afa9610",
   "metadata": {},
   "source": [
    "# Quadmesh Plot\n",
    "\n",
    "This example visualizes gridded air temperature data using a quadmesh. It works well with xarray datasets to display continuous variables over a regular 2D grid."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d91ff27-e75c-4ea3-96ca-e86830e3a1ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.xarray  # noqa\n",
    "import numpy as np\n",
    "import xarray as xr\n",
    "\n",
    "np.random.seed(42)\n",
    "# Irregular grid\n",
    "x = np.sort(np.random.uniform(0, 10, size=40))\n",
    "y = np.sort(np.random.uniform(0, 5, size=30))\n",
    "X, Y = np.meshgrid(x, y)\n",
    "data = np.sin(X) * np.cos(Y) * 3\n",
    "ds = xr.Dataset({\"value\": ([\"y\", \"x\"], data)}, coords={\"y\": y, \"x\": x})\n",
    "\n",
    "ds.hvplot.quadmesh(\n",
    "    x='x',\n",
    "    y='y',\n",
    "    cmap='viridis',\n",
    "    title='Quadmesh Plot (Bokeh)',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "608eac61-ae1c-4a0b-8f7b-664fd4002f9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.xarray  # noqa\n",
    "import numpy as np\n",
    "import xarray as xr\n",
    "hvplot.extension('matplotlib')\n",
    "\n",
    "np.random.seed(42)\n",
    "# Irregular grid\n",
    "x = np.sort(np.random.uniform(0, 10, size=40))\n",
    "y = np.sort(np.random.uniform(0, 5, size=30))\n",
    "X, Y = np.meshgrid(x, y)\n",
    "data = np.sin(X) * np.cos(Y) * 3\n",
    "ds = xr.Dataset({'value': (['y', 'x'], data)}, coords={'y': y, 'x': x})\n",
    "\n",
    "ds.hvplot.quadmesh(\n",
    "    x='x',\n",
    "    y='y',\n",
    "    cmap='viridis',\n",
    "    title='Quadmesh Plot (Matplotlib)',\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eb2dee10-8e25-4df8-b200-5e5153b33090",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Quadmesh reference documentation](../../ref/api/manual/hvplot.hvPlot.quadmesh.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
